package com.lixiaoyu.dao;

import com.lixiaoyu.entity.Express;
import com.lixiaoyu.entity.ExpressBox;

/**
 * 现在是用来存储快递数据的类
 */
public class ExpressDB {
    Express express = new Express();

    ExpressBox expressBox = new ExpressBox();

    //容量50
    //每个里头放4个数据:取件码-快递柜号-快递单号-快递公司
    String[][] EXPRESSBOX = new String[50][4];

    //账号
    String[] userName = new String[2];
    //密码
    int[] passWord = new int[2];
    //存放账号密码
    String[][] userPassWord = new String[2][2];


    //初始化数据
    {
        //取件码
        EXPRESSBOX[0][0] = "032301";
        //快递柜
        EXPRESSBOX[0][1] = "A01";
        //快递单号
        EXPRESSBOX[0][2] = "SF202103230001";
        //快递公司
        EXPRESSBOX[0][3] = "顺丰快递";
        //取件码
        EXPRESSBOX[1][0] = "032302";
        //快递柜
        EXPRESSBOX[1][1] = "A02";
        //快递单号
        EXPRESSBOX[1][2] = "SF202103230002";
        //快递公司
        EXPRESSBOX[1][3] = "顺丰快递";
        userName[0] = "user";
        userName[1] = "admin";
        passWord[0] = 123456;
        passWord[1] = 123456;
        //存放账号密码
        userPassWord[0][0] = userName[0];
        userPassWord[0][1] = Integer.toString(passWord[0]);
        userPassWord[1][0] = userName[0];
        userPassWord[1][1] = Integer.toString(passWord[1]);
    }

    /**
     * 查询快递信息
     * @param getExpressCode
     * @return
     */
    public String[][] getSelectUserExpress(int getExpressCode) {
        String[][] a = new String[1][4];
        for(int i = 0; i < EXPRESSBOX.length; i++){
            if(EXPRESSBOX[i][0].equals(Integer.toString(getExpressCode))){
                a[0][0] = EXPRESSBOX[i][0];
                a[0][1] = EXPRESSBOX[i][1];
                a[0][2] = EXPRESSBOX[i][2];
                a[0][3] = EXPRESSBOX[i][3];
                break;
            }

        }
        return a;
    }

    /**
     * 查询密码
     * @param userName : 账户
     * @return
     */
    public String[][] getUserPassWord(String userName) {
        int passWord = 0;
        String[][] up = new String[1][1];
        for(int i = 0; i < userPassWord.length; i++){
            if(userPassWord[i][0].equals(userName)){
                up[0][0] = userPassWord[i][0];
                up[0][1] = userPassWord[i][1];
                break;
            }
        }
        return up;
    }
}
